{% extends 'base.html' %}
{% block content %}

    <br>
<h1>分类:{{ category.name }}({{ category.posts|length }})</h1>
    <br>

<div class="row">
<div class="col-sm-8">
{% if posts %}
    {% for post in posts %}
        <h3 class="text-primary"><a href="{{ url_for('.show_post',slug=post.title) }}">{{ post.title }}</a></h3>
        <p>
            {{ post.body|striptags|truncate(100) }}
            <small><a href="{{ url_for('.show_post',slug=post.title) }}">阅读更多</a></small>
        </p>
        <small>
            评论: <a href="{{ url_for('.show_post',slug=post.title) }}#comments">{{ post.comments|length }}</a>&nbsp;&nbsp;
            分类: <a href="{{ url_for('.show_category',category_id=post.category.id) }}">{{ post.category.name }}</a>
            <span class="float-right">{{ moment(post.timestamp).format('LL') }}</span>
        </small>

        {% if not loop.last %}
        <hr>
        {% endif %}

    {% endfor %}

    {% else %}
    <div class="tip">
        <h5>还没有文章。</h5>
        {% if current_user.is_authenticated %}
            <a href="{{ url_for('admin.new_post') }}">现在就发布文章</a>

            {% endif %}
    </div>
{% endif %}
</div>

        <div class="col-sm-4 sidebar">
            {% include "_sidebar.html" %}
        </div>

</div>
    <br>
    <center>
    <div class="pagination" align="center">
{% from 'macros.html' import pager %}
    {{ pager(pagination) }}
        </div>
        </center>
{##}
{#{% from 'bootstrap/pagination.html' import render_pagination %}#}
{#    <div class="page-footer">{{ render_pagination(pagination) }}</div>#}
{% endblock %}